package com.ruoyi.testDeal.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.testDeal.domain.basic.YbBasicinfo;
import com.ruoyi.testDeal.service.IYbBasicinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 仪器仪通用检测项Controller
 * 
 * @author ruoyi
 * @date 2024-05-17
 */
@RestController
@RequestMapping("/yb/basicinfo")
public class YbBasicinfoController extends BaseController
{
    @Autowired
    private IYbBasicinfoService ybBasicinfoService;

    /**
     * 查询仪器仪通用检测项列表
     */
    @GetMapping("/list")
    public TableDataInfo list(YbBasicinfo ybBasicinfo)
    {
        startPage();
        List<YbBasicinfo> list = ybBasicinfoService.selectYbBasicinfoList(ybBasicinfo);
        return getDataTable(list);
    }

    /**
     * 导出仪器仪通用检测项列表
     */
    @Log(title = "仪器仪通用检测项", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YbBasicinfo ybBasicinfo)
    {
        List<YbBasicinfo> list = ybBasicinfoService.selectYbBasicinfoList(ybBasicinfo);
        ExcelUtil<YbBasicinfo> util = new ExcelUtil<YbBasicinfo>(YbBasicinfo.class);
        util.exportExcel(response, list, "仪器仪通用检测项数据");
    }

    /**
     * 获取仪器仪通用检测项详细信息
     */
    @GetMapping(value = "/{ybBasicId}")
    public AjaxResult getInfo(@PathVariable("ybBasicId") Long ybBasicId)
    {
        return success(ybBasicinfoService.selectYbBasicinfoByYbBasicId(ybBasicId));
    }

    /**
     * 新增仪器仪通用检测项
     */
    @Log(title = "仪器仪通用检测项", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YbBasicinfo ybBasicinfo)
    {
        return toAjax(ybBasicinfoService.insertYbBasicinfo(ybBasicinfo));
    }

    /**
     * 修改仪器仪通用检测项
     */
    @Log(title = "仪器仪通用检测项", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YbBasicinfo ybBasicinfo)
    {
        return toAjax(ybBasicinfoService.updateYbBasicinfo(ybBasicinfo));
    }

    /**
     * 删除仪器仪通用检测项
     */
    @Log(title = "仪器仪通用检测项", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ybBasicIds}")
    public AjaxResult remove(@PathVariable Long[] ybBasicIds)
    {
        return toAjax(ybBasicinfoService.deleteYbBasicinfoByYbBasicIds(ybBasicIds));
    }
}
